<?php
/**
 * Created by PhpStorm.
 * User: John
 * Date: 17-1-11
 * Time: 下午5:28
 */
use think\Loader;
use think\Model;
use think\Config;
if (PHP_SAPI !='cli') exit('error');
if ($argc==1) {
    echo str_pad("*", 50, "*"), PHP_EOL;
    echo str_pad("*", 19, " ")," HELP TIPS ",str_pad("*", 20, " ", STR_PAD_LEFT), PHP_EOL;
    echo str_pad("*", 4, " ")," php -f run ControllerName ActionName ",str_pad("*", 8, " ", STR_PAD_LEFT), PHP_EOL;
    echo str_pad("*", 50, "*"), PHP_EOL;
    exit;
}

//定义cli处理入口
define('ZFT_CLI', true);

include __dir__.'/../../public/index.php';

if (strpos($argv[1], '_')!==false) {
    list($module, $c) = explode('_', $argv[1]);
} else {
    exit('wrong access type!');
}

$action     = $argv[2];
$instance = Loader::parseClass($module, 'controller', $c, true);

Loader::addNamespace('app', __dir__.'/../');

if (class_exists($instance))
    $_object = new $instance();
else exit("Controller Not Exist\n");

if (method_exists($_object, $action))
    $_object->$action($argv);
else exit('Action Not Exist');


